import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  //静态
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primaryColor: Color.fromRGBO(51, 51, 51, 1),
      ),
      home: ReceivingOrdersING(),
    );
  }
}

class ReceivingOrdersING extends StatefulWidget {
  //动态
  @override
  _ReceivingOrdersINGState createState() => _ReceivingOrdersINGState();
}

class _ReceivingOrdersINGState extends State<ReceivingOrdersING> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Color.fromRGBO(51, 51, 51, 1),
          titleSpacing: 0.0,
          //头部
          title: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              FlatButton(
                materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                child: Row(
                  children: <Widget>[
                    Icon(
                      Icons.arrow_back_ios,
                      color: Colors.white,
                    ),
                    Text(
                      '返回',
                      style: TextStyle(color: Colors.white, fontSize: 16),
                    )
                  ],
                ),
                onPressed: () {
                  Navigator.pop(context);
                  //返回上一页
                },
              ),
              Container(
                child: Row(
                  children: <Widget>[
                    Text(
                      '跑腿待接单详情',
                      style: (TextStyle(color: Colors.white, fontSize: 16)),
                    ),
                    SizedBox(
                      width: 25,
                    )
                  ],
                ),
              ),
              IconButton(icon: Icon(Icons.more_horiz), onPressed: () {})
            ],
          ),
        ),
        body: Container(
          color: Color.fromRGBO(236, 236, 236, 1),
          child: Center(
              child: Column(children: <Widget>[
                Container(
                  child: Container(
                    padding: EdgeInsets.fromLTRB(15, 15, 15, 0),
                    color: Colors.white,
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        //跑腿加急
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: <Widget>[
                            Text(
                              "跑腿  加急",
                              style: TextStyle(fontSize: 15),
                            ),
                            Text(
                              "待接单",
                              style: TextStyle(fontSize: 16, color: Colors.red),
                              textAlign: TextAlign.right,
                            )
                          ],
                        ),
                        SizedBox(
                          height: 10,
                        ),
                        Text(
                          "任务主题 （限制20字）",
                          style: TextStyle(fontSize: 20),
                        ),
                        Divider(
                          color: Colors.grey,
                          height: 45,
                          thickness: 0.5,
                        ),

                        //已支付：8元
                        Row(
                          children: <Widget>[
                            Icon(
                              Icons.monetization_on,
                              color: Color.fromRGBO(50, 50, 50, 0.5),
                            ),
                            Text(
                              "  已支付： 8元",
                              style: TextStyle(fontSize: 16),
                            ),
                          ],
                        ),

                        //任务内容
                        Container(
                          width: 600,
                          child: Row(
                            children: <Widget>[
                              Icon(
                                Icons.mail_outline,
                                color: Color.fromRGBO(50, 50, 50, 0.5),
                              ),
                              Expanded(
                                child: Padding(
                                  padding: EdgeInsets.only(left: 0, top: 15),
                                  child: Text(
                                    "任务内容任务内容任务内容任务内容任务内容任务内容任务内容任务内容任务内容",
                                    style: TextStyle(fontSize: 16),
                                  ),
                                ),
                              )
                            ],
                          ),
                        ),
                        SizedBox(
                          height: 10,
                        ),
                        Divider(
                          color: Colors.grey,
                          height: 30,
                          thickness: 0.5,
                        ),

                        //发单人姓名
                        Row(
                          children: <Widget>[
                            Icon(Icons.pin_drop,
                                color: Color.fromRGBO(50, 50, 50, 0.5)),
                            Text(
                              "发单人姓名               15688888888",
                              style: TextStyle(fontSize: 16),
                            ),
                          ],
                        ),

                        //福建省
                        Container(
                          width: 600,
                          child: Row(
                            children: <Widget>[
                              Expanded(
                                child: Padding(
                                  padding: EdgeInsets.only(left: 5, top: 15),
                                  child: Text(
                                    "福建省厦门市",
                                    style: TextStyle(fontSize: 14),
                                  ),
                                ),
                              )
                            ],
                          ),
                        ),
                        Divider(
                          color: Colors.grey,
                          height: 55,
                          thickness: 0.5,
                        ),
                        Row(
                          children: <Widget>[
                            Icon(Icons.history,
                                color: Color.fromRGBO(50, 50, 50, 0.5)),
                            Text(
                              "发布时间：2017-6-20 18:00",
                              style: TextStyle(fontSize: 16),
                            ),
                          ],
                        ),
                        SizedBox(
                          height: 15,
                        ),
                      ],
                    ),
                  ),
                ),

                //取消订单
                Spacer(),
                Container(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: <Widget>[
                      MaterialButton(
                          child: Text(
                            "取消订单",
                            style: TextStyle(color: Colors.black87, fontSize: 16),
                          ),
                          shape: BeveledRectangleBorder(
                            side: BorderSide(width: 1, color: Colors.grey),
                            borderRadius: BorderRadius.circular(3),
                          ),
                          onPressed: () {
                            String dropdownValue = '原因1';
                            showDialog(
                              context: context,
                              builder: (BuildContext context) {
                                return DemoDialog();
                              },
                            );



                          }
                      ),
                      Text("     "),
                    ],
                  ),
                  color: Colors.white,
                ),
              ])),
        ),
      ),
    );
  }
}

class DemoDialog extends StatefulWidget {
  @override
  DemoDialogState createState() => new DemoDialogState();
}

class DemoDialogState extends State<DemoDialog> {
  String dropdownValue = '原因1';
  @override
  Widget build(BuildContext context) {
    return Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      child: new Center(
        //保证控件居中效果
        child: new SizedBox(
          width: 300.0,
          height: 200.0,
          child: Container(
            decoration: BoxDecoration(
                border: new Border.all(color: Colors.black, width: 0.5),
                color: Colors.white),
            child: Column(
              children: <Widget>[
                SizedBox(
                  height: 10,
                ),
                Text(
                  "取消原因",
                  style: TextStyle(fontSize: 20),
                ),
                SizedBox(
                  height: 30,
                ),
                Container(
                  width: 100,
                  height: 23,
                  decoration: BoxDecoration(
                      border: new Border.all(color: Colors.black, width: 1),
                      color: Colors.white),
                  child: DropdownButton<String>(
                    value: dropdownValue,
                    isExpanded: true,
                    onChanged: (String newValue) {
                      setState(() {
                        dropdownValue = newValue;
                      });
                    },
                    items: <String>['原因1', '原因2', '原因3', '原因4']
                        .map<DropdownMenuItem<String>>((String value) {
                      return DropdownMenuItem<String>(
                        value: value,
                        child: Text(value),
                      );
                    }).toList(),
                  ),
                ),
                Spacer(),
                Row(
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        child: Center(
                          child: FlatButton(
                            highlightColor: Color.fromRGBO(255, 255, 255, 0),
                            child: Text("确认"),
                            onPressed: () {},
                          ),
                        ),
                        decoration: BoxDecoration(
                          border:
                          new Border.all(color: Colors.black, width: 0.5),
                        ),
                      ),
                    ),
                    Expanded(
                      child: Container(
                        child: Center(
                          child: FlatButton(
                            highlightColor: Color.fromRGBO(255, 255, 255, 0),
                            child: Text("取消"),
                            onPressed: () {
                              Navigator.pop(context);
                            },
                          ),
                        ),
                        decoration: BoxDecoration(
                          border:
                          new Border.all(color: Colors.black, width: 0.5),
                        ),
                      ),
                    )
                  ],
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

//取消订单




